/*
 * Copyright 2009 Colin Prinn
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package net.recursv.motific.at.scene;

/**
 * Created by: recursv
 * Date: 9/08/2009
 * Time: 9:00:23 AM
 */
class GraphicsTask {
    private final String _name;
    private int _width = -1;
    private int _height = -1;
    private int _color = -1;
    private int _x = Integer.MAX_VALUE;
    private int _y = Integer.MAX_VALUE;
    private String _text;

    public GraphicsTask(String name) {
        _name = name;
    }

    public String getName() {
        return _name;
    }

    public int getWidth() {
        return _width;
    }

    public int getHeight() {
        return _height;
    }

    public int getColor() {
        return _color;
    }

    public int getX() {
        return _x;
    }

    public int getY() {
        return _y;
    }

    public void setX(int x) {
        _x = x;
    }

    public void setY(int y) {
        _y = y;
    }

    public void setWidth(int width) {
        _width = width;
    }

    public void setHeight(int height) {
        _height = height;
    }

    public void setColor(int color) {
        _color = color;
    }

    public void setText(String text) {
        _text = text;
    }

    public String getText() {
        return _text;
    }

    public void mergeWith(GraphicsTask task) {
        _x = Math.min(_x, task.getX());
        _y = Math.min(_y, task.getY());
        _width = Math.max(_width, task._width);
        _height = Math.max(_height, task._height);
        if (_color == -1)
            _color = task._color;
        if (_text == null || _text.length() == 0)
            _text = task._text;
    }
}
